import 'package:flutter/material.dart';
import 'package:lib_uikit/lib_uikit.dart';

///textTop文案在上面，数字在下面
enum GTNumberTypeV3 { textTop, numberTop }

///number字体大小
enum GTNumberSizeV3 { size28, size24, size20, size16, size13 }

///text文案位于number水平位置：左中右
enum GTNumberTextPositionV3 { start,center,end }

///number：数值显示
class GTNumberViewV3 extends StatelessWidget {
  final GTNumberTypeV3? type;
  final GTNumberSizeV3? size;
  //文案内容
  final String text;
  //数字内容
  final String number;
  final GTNumberTextPositionV3 position;
  final IconData? titleIcon;
  const GTNumberViewV3({
    super.key,
    this.type = GTNumberTypeV3.textTop,
    this.size = GTNumberSizeV3.size28,
    this.position = GTNumberTextPositionV3.start,
    required this.text,
    required this.number,
    this.titleIcon,
  });

  @override
  Widget build(BuildContext context) {
    double textSize = 13;
    double numberSize=28;
    TextStyle numberWeight = gtTextStyleW700();
    double height = 4;
    Color textColor= GTColorsV3.text3.color;
    double iconSize=16,iconMargin=8;
    switch (size) {
      case GTNumberSizeV3.size28:
        numberSize = 28;
        height = 8;
        textColor = GTColorsV3.text2.color;
        break;
      case GTNumberSizeV3.size24:
        numberSize = 24;
        break;
      case GTNumberSizeV3.size20:
        textSize = 12;
        numberSize = 20;
        break;
      case GTNumberSizeV3.size16:
        textSize = 12;
        numberSize = 16;
        break;
      case GTNumberSizeV3.size13:
        textSize = 11;
        numberSize = 16;
        iconSize=12;
        iconMargin=4;
        numberWeight = gtTextStyleW500();
        break;
      case null:
        numberSize = 28;
        height = 8;
        textColor = GTColorsV3.text2.color;
        iconSize=12;
        iconMargin=4;
        break;
    }

    CrossAxisAlignment crossAxisAlignment;
    switch(position){
      case GTNumberTextPositionV3.start:
        crossAxisAlignment = CrossAxisAlignment.start;
        break;
      case GTNumberTextPositionV3.center:
        crossAxisAlignment = CrossAxisAlignment.center;
        break;
      case GTNumberTextPositionV3.end:
        crossAxisAlignment = CrossAxisAlignment.end;
        break;
    }

    return Column(
      mainAxisSize: MainAxisSize.min,
      crossAxisAlignment: crossAxisAlignment,
      children: [
        if(type==GTNumberTypeV3.textTop)...[
          Row(
            mainAxisSize: MainAxisSize.min,
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Text(
                text,
                style: gtTextStyleW400(fontSize: textSize, color: textColor),
              ),
              if(titleIcon!=null)...[
                SizedBox(
                  width: iconMargin,
                ),
                Icon(titleIcon,size: iconSize,color: GTColorsV3.icon3.color,)
              ]
            ],
          ),
          SizedBox(
            height: height,
          ),
        ],
        Text(
          number,
          style: numberWeight.copyWith(fontSize: numberSize, color: GTColorsV3.text1.color),
        ),
        if(type==GTNumberTypeV3.numberTop)...[
          SizedBox(
            height: height,
          ),
          Row(
            mainAxisSize: MainAxisSize.min,
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Text(
                text,
                style: gtTextStyleW400(fontSize: textSize, color: textColor),
              ),
              if(titleIcon!=null)...[
                SizedBox(
                  width: iconMargin,
                ),
                Icon(titleIcon,size: iconSize,color: GTColorsV3.icon3.color,)
              ]
            ],
          ),
        ]
      ],
    );
  }
}
